Skip to content

Improve the behaviour when rejecting a call while already in an active call - #1482

Merged
aleksandar-apostolov merged 30 commits into
developfrom
feature/rahullohra/handle-call-reject-on-new-intent
Aug 1, 2025
Merged

Improve the behaviour when rejecting a call while already in an active call#1482
aleksandar-apostolov merged 30 commits into
developfrom
feature/rahullohra/handle-call-reject-on-new-intent

Conversation

@rahul-lohra

@rahul-lohra rahul-lohra commented Aug 1, 2025

Copy link
Copy Markdown
Contributor

🎯 Goal

Improve call rejection from Notification Button

🛠 Implementation details

"The UI observes Call.state.rejectedBy. If the value indicates the current user, the code will attempt to close the activity, provided there is no active call."

/**
           * Call can be rejected by [RejectCallBroadcastReceiver] so the activity
           * needs to observe [Call.state.rejectedBy]
           */
          val rejectedBy by call.state.rejectedBy.collectAsStateWithLifecycle()
          LaunchedEffect(rejectedBy) {
              val currentUserId = StreamVideo.instanceOrNull()?.userId
              if (rejectedBy.contains(currentUserId)) {
                  // check if there is no ongoing call then safely finish it else do nothing
                  val noActiveCall = (StreamVideo.instanceOrNull()?.state?.activeCall?.value == null)
                  if (noActiveCall) {
                      onEnded(call)
                      val configuration = configurationMap[call.id]
                      if (configuration?.closeScreenOnCallEnded == true) {
                          safeFinish()
                      } else {
                          logger.d { "Don't close activity as some other call is active" }
                      }
                  }
              }
          }

We are updating rejectedBy from the RejectCallBroadcastReceiver

internal class RejectCallBroadcastReceiver : GenericCallActionBroadcastReceiver() {


    override suspend fun onReceive(call: Call, context: Context, intent: Intent) {
        when (val rejectResult = call.reject(RejectReason.Decline)) {
            is Result.Success -> {
                val userId = StreamVideo.instanceOrNull()?.userId
                userId?.let {
                    val set = mutableSetOf(it)
                    call.state.updateRejectedBy(set)
                }
                logger.d { "[onReceive] rejectCall, Success: $rejectResult" }
            }            
        ...
    }
}

@rahul-lohra
rahul-lohra requested a review from a team as a code owner August 1, 2025 08:10
@rahul-lohra rahul-lohra self-assigned this Aug 1, 2025
@github-actions

github-actions Bot commented Aug 1, 2025

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-video-android-core 11.43 MB 11.43 MB 0.00 MB 🟢
stream-video-android-ui-xml 5.70 MB 5.70 MB 0.00 MB 🟢
stream-video-android-ui-compose 5.88 MB 5.89 MB 0.02 MB 🟢

@sonarqubecloud

sonarqubecloud Bot commented Aug 1, 2025

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
4.4% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)
E Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@aleksandar-apostolov aleksandar-apostolov changed the title Improve call rejection from Notification Button Improve the behaviour when rejecting a call while already in an active call Aug 1, 2025
@aleksandar-apostolov aleksandar-apostolov added the pr:improvement Enhances an existing feature or code label Aug 1, 2025
@aleksandar-apostolov
aleksandar-apostolov merged commit 81ff030 into develop Aug 1, 2025
11 of 16 checks passed
@aleksandar-apostolov
aleksandar-apostolov deleted the feature/rahullohra/handle-call-reject-on-new-intent branch August 1, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:improvement Enhances an existing feature or code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants